package com.gfxy.modules.items.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gfxy.modules.excel.ExcelUtil;
import com.gfxy.modules.items.entity.Fdysznlds;
import com.gfxy.modules.items.entity.Jxnlds;
import com.gfxy.modules.items.mapper.FdysznldsMapper;
import com.gfxy.modules.items.service.IFdysznldsService;
import com.gfxy.modules.items.vo.BzscMemberPage;
import com.gfxy.modules.items.vo.FdysznldsMemberPage;
import org.apache.poi.ss.usermodel.Row;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.List;
import java.util.Collection;

/**
 * @Description: 辅导员素质能力大赛
 * @Author: jeecg-boot
 * @Date:   2023-12-26
 * @Version: V1.0
 */
@Service
public class FdysznldsServiceImpl extends AbstractProjectServiceImpl<FdysznldsMapper, Fdysznlds> implements IFdysznldsService {

	public FdysznldsServiceImpl() {
		this.memberCellNum = 3;
	}
	@Override
	public IPage<FdysznldsMemberPage> selectListPage(String date, Integer pageNo, Integer pageSize) {
		Page<FdysznldsMemberPage> page = new Page<>(pageNo, pageSize);

		Page<FdysznldsMemberPage> page1 = page.setRecords(baseMapper.selectMemberPageListByYear(date));

		return page1;
	}

	@Override
	public List<FdysznldsMemberPage> getMemberPageListByYear(String date) {
		return baseMapper.selectMemberPageListByYear(date);
	}

	@Override
	public Double getTotalScore(Fdysznlds fdysznlds) {
		double result = 0.0;
		int level = fdysznlds.getLevel();
		int classess = fdysznlds.getClassess();
		if(level == 1){
			if(classess == 1){
				result = 150;
			} else if(classess == 2 ) {
				result = 120;
			} else if(classess == 3 ) {
				result = 100;
			}
		} else if(level == 2){
			if(classess == 1){
				result = 50;
			} else if(classess == 2 ) {
				result = 30;
			} else if(classess == 3 ) {
				result = 20;
			}
		} else if(level == 3){
			if(classess == 1){
				result = 15;
			} else if(classess == 2 ) {
				result = 10;
			} else if(classess == 3 ) {
				result = 5;
			}
		}

		return result;
	}

	@Override
	protected Fdysznlds getOneProject(Row row) {
		String date = ExcelUtil.formatCell(row.getCell(0));

		String level  = ExcelUtil.formatCell(row.getCell(1));
		String classess = ExcelUtil.formatCell(row.getCell(2));


		Fdysznlds fdysznlds = new Fdysznlds();

		fdysznlds.setDate(date);
		fdysznlds.setLevel(translateLevel(level));
		fdysznlds.setClassess(translateClassess(classess));
		fdysznlds.setProjectName("");
		fdysznlds.setIsPass(0);
		//这个地方不要忘了-算总分
		fdysznlds.setTotalScore(this.getTotalScore(fdysznlds));
		return fdysznlds;
	}

	private Integer translateClassess(String classess) {
		if (classess == null || classess.equals("") ) {
			return 0;
		} else if (classess.equals("一等奖")) {
			return 1;
		} else if (classess.equals("二等奖")) {
			return 2;
		}else if (classess.equals("三等奖")){
			return 3;
		}else {
			return 0;
		}
	}

	private Integer translateLevel(String level) {
		if(level == null || level.equals("")){
			return 0;
		} else if(level.equals("国家级")){
			return 1;
		} else if(level.equals("省级")){
			return 2;
		} else if(level.equals("校级")){
			return 3;
		} else {
			return 0;
		}
	}


}
